package com.l024.easyandroidlib.event;

import android.view.View;

/**
 * 双击事件
 */
public class DoubleClickEvent implements View.OnClickListener {
    int count = 0;
    long time = 0;
    private OnDoubleClickListener onDoubleClickListener = null;

    public DoubleClickEvent(OnDoubleClickListener onDoubleClickListener) {
        this.onDoubleClickListener = onDoubleClickListener;
    }

    @Override
    public void onClick(View view) {
        count++;
        if (System.currentTimeMillis()-time < 5000 && count>1) {
            if(onDoubleClickListener!=null){
                onDoubleClickListener.OnDoubleClick();
                count = 0;
            }
        }else {
            time = System.currentTimeMillis();
        }

    }

    public interface OnDoubleClickListener{
        public void OnDoubleClick();
    }
}
